//package com.redsoft.spirit.mq;
//
//import org.springframework.amqp.core.Queue;
//import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
//import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//
//@Configuration
//public class RabbitConfig {
//
//	@Bean
//	@Primary
//	public ConnectionFactory connectionFactory(@Value("${spring.rabbitmq.first.host}") String host,
//			@Value("${spring.rabbitmq.first.port}") int port,
//			@Value("${spring.rabbitmq.first.username}") String username,
//			@Value("${spring.rabbitmq.first.password}") String password) {
//		CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
//		connectionFactory.setHost(host);
//		connectionFactory.setPort(port);
//		connectionFactory.setUsername(username);
//		connectionFactory.setPassword(password);
//		connectionFactory.setPublisherConfirms(true); //必须要设置 
//		return connectionFactory;
//	}
//
//	@Bean
//	@Primary
//	public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
//		RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
//		rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
////		rabbitTemplate.setMandatory(true);
////        rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {
////        	System.out.println("这是回调吗：" + ack);
////            if (!ack) {
////
////            } 
////        });
//		return rabbitTemplate;
//	}
//
//	@Bean
//	public SimpleRabbitListenerContainerFactory factory(SimpleRabbitListenerContainerFactoryConfigurer configurer,
//			 ConnectionFactory connectionFactory) {
//		SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
//		factory.setMessageConverter(new Jackson2JsonMessageConverter());
//		configurer.configure(factory, connectionFactory);
//		
//		return factory;
//	}
//
//	@Bean
//	public Queue firstQueue() {
//		System.out.println("configuration firstQueue ........................");
//		return new Queue("hello1");
//	}
//
//	@Bean
//	public Object secondQueue() {
//		System.out.println("configuration secondQueue ........................");
//		return new Queue("hello2");
//	}
//}